package multithread;

/**
 * @Author: zhangrongqing
 * @Date: 2019/12/19 10:53
 */
public class SychronizedDemo {
    public static synchronized void test(){
        System.out.println("test Method");
    }

    public static synchronized void test2(){
        System.out.println("test2 Method");
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            SychronizedDemo demo = new SychronizedDemo();
            synchronized (SychronizedDemo.class){
                System.out.println(Thread.currentThread().getName() + "heiheihei");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("========================");
                    System.out.println(Thread.currentThread().getName() + "test");
                    SychronizedDemo.test();
                    SychronizedDemo.test2();
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }).start();

        }
    }
}
